<link href="css/index.css" rel="stylesheet" type="text/css" />

<body id="dd">
<?php header("content-type:text/html; charset=utf-8"); 
include_once 'conn.php';
if(!empty($_POST['post'])){
    $username = $_POST['username'];
    $email = $_POST['email'];
    $content = $_POST['content'];   
    
   $sql = "insert into reply ( id,username,email,contet) values ( null, '$username','$email','$content')";
   $result = $conn->query($sql);
  
   
     if($result === TRUE){
         echo "<script type'text/javascript'>alert('留言成功！');location.href='index.php'</script>";
     }  else {
         echo "<script type'text/javascript'>alert('留言失败！');location.href='index.php'</script>";    
     }
}

?>
    <?php
$sql = "SELECT * FROM  message";
$result = $conn->query($sql);

$arrlist = array();

if ($result->num_rows > 0) {  
    // 输出每行数据
    while($row = $result->fetch_assoc()) {
        array_push($arrlist, $row);        
    }
} else {
    echo "0 results";
}
$conn->close();          
           ?>            
<?php
foreach ($arrlist as $vo){
?>

            
<dl class='paper a1'>
			<dt>
				<span class='username'><?php  echo $vo['username']; ?></span>
				<span class='num'>No.0000<?php  echo $vo['id']; ?></span>
			</dt>
			<dd class='content'><?php  echo ($vo[ 'content']); ?></dd>
			<dd class='bottom'>
				<span class='time'><?php  echo $vo['email']; ?></span>
				<a href="" class='close'></a>
			</dd>
		</dl>  
<?php    }   ?>
	
<hr/>	
<form action="sda.php" method="post">
<div id="as">
    <table border="0" width="500" class="ds">
        <tr>
            <td width="100" align="right">用户名：</td>
            <td><input type="text" name="username" value=""/></td>
        </tr>
        <tr>
            <td width="100" align="right">E-mail：</td>
            <td><input type="text" name="email"/></td>
        </tr>
        <tr>
            <td width="100" align="right">留言内容：</td>
            <td><textarea name="content"></textarea></td>
        </tr>
        <tr>
            <td colspan="2" align="center"><input type="submit" name="post" value="留言"/></td>
        </tr></table></div>
</form>
</body>